﻿using Microsoft.Xna.Framework.Input;

namespace BattleLogic
{
	public class Controls
	{
		private bool isLeftButtonPress = false;

		#region Properties
		public bool isExit { get; private set; }

		public bool isBeginNewRound { get; private set; }

		public bool isCameraMoveUp { get; private set; }
		public bool isCameraMoveDown { get; private set; }
		public bool isCameraMoveLeft { get; private set; }
		public bool isCameraMoveRight { get; private set; }
		public bool isCameraZoomIn { get; private set; }
		public bool isCameraZoomOut { get; private set; }

		public bool isChangeView { get; private set; }
		#endregion


		private void SetDefaultValues()
		{
			this.isExit = false;
			this.isBeginNewRound = false;
			this.isCameraMoveDown = false;
			this.isCameraMoveLeft = false;
			this.isCameraMoveRight = false;
			this.isCameraMoveUp = false;
			this.isChangeView = false;
			this.isCameraZoomIn = false;
		}

		public void Check(KeyboardState keybordState, MouseState mouseState)
		{
            //Set default values
			this.SetDefaultValues();

			#region Keyboard
			//Exit from the game
			this.isExit = keybordState.IsKeyDown(Keys.Escape);

			//Begin new round
			if (keybordState.IsKeyDown(Keys.Space) || keybordState.IsKeyDown(Keys.Enter))
				this.isBeginNewRound = true;

            if (keybordState.IsKeyDown(Keys.Left))
			//Move camera left
			this.isCameraMoveLeft = keybordState.IsKeyDown(Keys.Left);

			//Move camera right
			this.isCameraMoveRight = keybordState.IsKeyDown(Keys.Right);

			//Move camera up
			this.isCameraMoveUp = keybordState.IsKeyDown(Keys.Up);

            if (keybordState.IsKeyDown(Keys.Down))
			//Move camera down
			this.isCameraMoveDown = keybordState.IsKeyDown(Keys.Down);

			//Camera zoom in
			this.isCameraZoomIn = keybordState.IsKeyDown(Keys.OemPlus);

			//Camera zoom out
			this.isCameraZoomOut = keybordState.IsKeyDown(Keys.OemMinus);
			#endregion

			#region Mouse
			if (mouseState.LeftButton == ButtonState.Released)
				this.isLeftButtonPress = false;

			if (mouseState.LeftButton == ButtonState.Pressed && !this.isLeftButtonPress)
			{
				this.isChangeView = true;

				this.isLeftButtonPress = true;
			}
			#endregion

		}
	}
}
